<template>
    <div v-cloak class="body bg-body" style="padding: 30px 0 60px">
        <div class="w">
            <div class="bg-white" style="min-height: 400px">
                <div v-if="!listLength" class="p-30 txt-info">暂无案例~</div>
                <div v-else>
                    <div
                        style="padding: 20px 15px 20px 30px"
                        v-for="(item, index) in list"
                        :key="index"
                    >
                        <router-link
                            :to="`/smartEnergy/energyDetail/${item.UIDS}`"
                            tag="div"
                            class="flex cur-p"
                        >
                            <img
                                :src="`${imgPrefix}${item.GOOD_LOGO}`"
                                width="140"
                                height="140"
                            />
                            <div style="padding-left: 20px">
                                <h3 class="fs-bold txt-tit fs-18">
                                    {{ item.GOOD_NAME }}
                                </h3>
                                <p class="txt-info" style="margin-top: 20px">
                                    {{ item.GOOD_DESC }}
                                </p>
                            </div>
                        </router-link>
                    </div>
                </div>
            </div>
            <div style="margin-top: 30px" v-if="listLength > 0">
                <el-pagination
                    background
                    layout="pager, next"
                    :page-size="pageSize"
                    :total="listLength"
                    @current-change="handleCurrentChange"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
    export default {
        name: 'energyList',
        data() {
            return {
                list: [],
                pageSize: 5,
                listLength: 0,
                imgPrefix: this.$store.getters.imgUrl,
            }
        },
        methods: {
            handleCurrentChange(currentPage) {
                this.getEneygyList(currentPage)
            },
            getEneygyList(currentPage) {
                let params = {
                    pageSize: 5,
                    currentPage,
                    product: [],
                    antistop: [],
                    BUSINESS_RANGE: 'B',
                    GOOD_NAME: null,
                    sort: { name: 'SHELF_TIME', esc: 'desc' },
                    isShow: true,
                }
                this.$http.getGoodsList({ datamsg: params }).then((res) => {
                    if (res.state == '0') {
                        this.$message.error(res.msg)
                        return
                    }
                    res = res.data
                    this.list = res.goodsList
                    this.listLength = res.total
                })
            },
        },
        created() {
            this.getEneygyList(1)
        },
    }
</script>



